package com.zhaopin.gitlab;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;

@Slf4j
public class CheckMainGroovy {


    //职位推荐名称
    static String projectName = "project";
    //职位搜索名称
//    static String projectName = "position";
    static String readFileName = projectName.equals("project") ? "dir/gitlab/project.txt" : "dir/gitlab/position.txt";
    static String RPOJECT_NAME_FILE = "/Users/zhaopin/IdeaProjects/easyjar/dir/gitlab/" + projectName + "/ "+projectName +"/";

    public static void main(String[] args) throws IOException {

        List<String> fileList = FileUtils.readLines(new File(readFileName), Charset.defaultCharset());

        for (String projectFileName : fileList) {

            //下面拼接main文件的实际路径
            // /Users/zhaopin/IdeaProjects/position/config-position_search-position_campus_query-COMPANY-c_campus_outlink_filter_v1/project/src/main/java/config/main.groovy:SOU_CONTENT,SOU_POSITION_NAME,SOU_POSITION_NAME_QUERY,
            String mainGroovyFileName = "/Users/zhaopin/IdeaProjects/"+projectName+"/" + projectFileName + "/project/src/main/java/config/main.groovy";
            String s = FileUtils.readFileToString(new File(mainGroovyFileName), Charset.defaultCharset());
            FileUtils.write(new File(RPOJECT_NAME_FILE+ projectFileName) ,s,Charset.defaultCharset(),true);


        }

    }


}
